﻿// code04090000.cpp : sizeof 运算符
// sizeof

#include <iostream>
using namespace std;
int main()
{
	int num = 10;
	cout << "num的sizeof：" << sizeof (num)<<endl;//int 4
	string str = "hello!";
	cout << "str的sizeof：" << sizeof(str) << endl;//string 40
	int* ptr1=&num;
	cout << "*ptr1的sizeof：" << sizeof(*ptr1) << endl;//int 4
	cout << "ptr1的sizeof：" << sizeof(ptr1) << endl;//指针类型 8
	string* ptr2 = &str;
	cout << "*ptr2的sizeof：" << sizeof(*ptr2) << endl;//string 40
	cout << "ptr2的sizeof：" << sizeof(ptr2) << endl;//指针类型 8

	void* ptr3 = &num;
	cout << "ptr3的sizeof：" << sizeof(ptr3) << endl;//void类型指针 8
	ptr3 = &str;
	cout << "ptr3的sizeof：" << sizeof(ptr3) << endl;//void类型指针 8
	ptr3 = nullptr;
	cout << "ptr3的sizeof：" << sizeof(ptr3) << endl;//void类型指针 8

	return 0;
    

}


